package com.als.sistema.cliente;

import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;

public class HibernateUtil {
	 
	  private static SessionFactory sessionFactory;
	  private static ServiceRegistry serviceRegistry;
	 
	  private static SessionFactory configureSessionFactory() throws HibernateException {
	      Configuration configuration = new Configuration();
	      configuration.configure();
	      serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();        
	      sessionFactory = configuration.buildSessionFactory(serviceRegistry);
	      return sessionFactory;
	  }
	 
	 
	    public static SessionFactory getSessionFactory() {
	        return configureSessionFactory();
	    }
	   
}
